package gui.menu;

import gui.GUI;
import gui.MenuButton;

import javax.swing.JPanel;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.SwingConstants;

import data.Player;
import javax.swing.JButton;

import control.SelectPlayersMenuManager;

public class SelectPlayersMenu extends JPanel {

	/**
	 * Create the panel.
	 */
	public SelectPlayersMenu() {
		super();

	}

	public void init(Player[] availablePlayers, SelectPlayersMenuManager manager){
		setLayout(new BorderLayout(0, 0));
		
		setBackground(GUI.BGMENU);
		JLabel lblSelectPlayers = new JLabel("Select players");
		lblSelectPlayers.setForeground(GUI.FGMENU);
		lblSelectPlayers.setHorizontalAlignment(SwingConstants.CENTER);
		lblSelectPlayers.setFont(new Font("Comic Sans MS", Font.BOLD, 24));
		add(lblSelectPlayers, BorderLayout.NORTH);
		
		JPanel playersPane = new JPanel();
		playersPane.setBackground(GUI.BGMENU);
		add(playersPane, BorderLayout.CENTER);
		playersPane.setLayout(new GridLayout(1, availablePlayers.length, 5, 0));
		
		JPanel buttonPane = new JPanel();
		buttonPane.setBackground(GUI.BGMENU);
		add(buttonPane, BorderLayout.SOUTH);
		
		JButton btnBack = new MenuButton("BACK",manager);
		btnBack.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
		buttonPane.add(btnBack);
		
		JButton btnStartGame = new MenuButton("START GAME",manager);
		btnStartGame.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
		buttonPane.add(btnStartGame);
		for (Player pl : availablePlayers) {
			playersPane.add(new SelectMenuPlayerPane(pl, manager));
		}
		}
}
